package com.yexiao.cofe.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yexiao.cofe.business.pojo.Product;
import com.yexiao.cofe.business.pojo.StoreProduct;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author lkl
 * @since 2025/3/31
 */
@Mapper
public interface StoreProductMapper extends BaseMapper<StoreProduct> {

    @Update("update store_product set price = #{price} where store_id = #{storeId} and product_id = #{productId}")
    void modifyPrice(String storeId, Integer productId, Double price);

    @Select("select * from store_product where store_id = #{storeId}")
    List<StoreProduct> selectByStoreId(String storeId);

    @Select("select * from store_product where store_id = #{storeId} and product_id = #{productId}")
    StoreProduct selectByStoreIdAndProductId(@Param("storeId") String storeId, @Param("productId") Integer productId);

    @Update("update store_product set status = #{status} where store_id = #{storeId} and product_id = #{productId}")
    void opProductStatus(@Param("storeId") String storeId, @Param("productId") Integer productId, @Param("status") Integer status);

    @Delete("delete from store_product where store_id = #{storeId} and product_id = #{productId}")
    void delByStoreIdAndProductId(@Param("storeId") String storeId, @Param("productId") Integer productId);

    @Select("select param_template_id from store_product where store_id = #{storeId} and product_id = #{productId}")
    Integer selectTemplateIdByStoreIdAndProductId(@Param("storeId") String storeId, @Param("productId") Integer productId);
}
